<?php

class Logs
{
    static $_dir = '';
    static $_file = '';
    
    static function init( $pre )
    {
        self::$_dir = BASE_PATH.'/log/';
        self::$_file = self::$_dir . $pre . '_' . date('Y-m-d') . '.txt';
    }

	static function strinfo( $obj )
	{
        $str = '';
        if( is_array( $obj ) )
        {
            foreach( $obj as $key=>$one )
            {
                $str .= ','.$key.'='.print_r( $one, true );
            }
        }
        else
        {
            $str .= var_dump( $obj );
        }
        return $str;
	}
    
    static function info( $obj )
    {
        $time = date( 'Y-m-d H:i:s' );
        return file_put_contents( self::$_file, $time. self::strinfo( $obj )."\n", FILE_APPEND );        
    }

}

if( isset($argv) && isset($argv[0]) && $argv[0] == basename(__FILE__))
{
	$obj = TextDealer::getInstance();
	$url = 'www.baidu.com';
	$r = $obj->downloadUrl($url);
	echo $r."\n";
}
